package com.ctshk.rpc.order.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.order.tour.dto.SeriesOrderDiscountListDTO;
import com.ctshk.rpc.order.tour.entity.SeriesOrderDiscount;
import com.ctshk.rpc.order.tour.req.SeriesOrderDiscountListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * <p>
 * 系列团折扣记录 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-01-22
 */
public interface SeriesOrderDiscountMapper extends BaseMapper<SeriesOrderDiscount> {

    @SelectProvider(type = SeriesOrderDiscountProvider.class, method = "selectListBySelective")
    IPage<SeriesOrderDiscountListDTO> selectListBySelective(IPage<SeriesOrderDiscountListReq> pageParam, @Param("req") SeriesOrderDiscountListReq req);

    /**
     * 查询用户折扣记录
     * @param orderId
     * @param touristId
     * @return
     */
    @Select("SELECT*\n" +
            "FROM t_series_order_discount\n" +
            "WHERE order_id = #{order_id} AND tourist_id = #{tourist_id} AND is_deleted = 0 AND (check_status = 2 OR check_status = 3)")
    List<SeriesOrderDiscount> queryByTourist(@Param("order_id") Long orderId,@Param("tourist_id") Long touristId);
}
